print('------')
from mpython import *
import Teno_Brain.RSaD as R
import Teno_Brain.KITS.UI as UI
print('kenny_desclock.py')

func = 1

def clock():
    R.f_tme_()
    UI.articles_('时钟', str(R.tme_mon_) + '月' + str(R.tme_dat_) + '日' + str(R.tme_hou_) + ':' + str(R.tme_min_), [0X03,0X80,0X1F,0XF0,0X3F,0XF8,0X7E,0XFC,0X7E,0XFC,0XFE,0XFC,0XFE,0XFE,0XFE,0X7E,0XFF,0X1E,0XFF,0XDE,0X7F,0XFC,0X7F,0XFC,0X3F,0XF8,0X1F,0XF0,0X07,0XC0])

def timer():
    R.f_tme_()
    UI.articles_('秒表', '暂不支持')

def funcs():
    choice = 1
    while True:
        UI.items_('桌面时钟', ['时钟', '秒表'], choice)
        R.f_toh_()
        if R.sig_toh_ == 'ON':
            choice += 1
        elif R.sig_toh_ == 'PY':
            choice -= 1
        elif R.sig_toh_ == 'TH':
            func = choice
            break
        elif choice <= 0:
            choice = 1
        elif choice >= 3:
            choice = 2

while True:
    R.f_toh_()
    R.f_but_()
    if func == 1:
        clock()
    elif func == 0:
        funcs()
    elif func == 2:
        timer()
    if R.val_but_ == 'B':
        func = 0